package com.ruoyi.project.loan.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.loan.domain.LoanApplication;
import com.ruoyi.project.loan.mapper.LoanApplicationMapper;
import com.ruoyi.project.loan.service.ILoanApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 贷款申请Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-11
 */
@Service
public class LoanApplicationServiceImpl implements ILoanApplicationService {
    @Autowired
    private LoanApplicationMapper loanApplicationMapper;

    /**
     * 查询贷款申请
     *
     * @param applicationId 贷款申请主键
     * @return 贷款申请
     */
    @Override
    public LoanApplication selectLoanApplicationByApplicationId(Long applicationId) {
        return loanApplicationMapper.selectLoanApplicationByApplicationId(applicationId);
    }

    /**
     * 查询贷款申请列表
     *
     * @param loanApplication 贷款申请
     * @return 贷款申请
     */
    @Override
    public List<LoanApplication> selectLoanApplicationList(LoanApplication loanApplication) {
        return loanApplicationMapper.selectLoanApplicationList(loanApplication);
    }

    /**
     * 新增贷款申请
     *
     * @param loanApplication 贷款申请
     * @return 结果
     */
    @Override
    public int insertLoanApplication(LoanApplication loanApplication) {
        loanApplication.setCreateTime(DateUtils.getNowDate());
        return loanApplicationMapper.insertLoanApplication(loanApplication);
    }

    /**
     * 修改贷款申请
     *
     * @param loanApplication 贷款申请
     * @return 结果
     */
    @Override
    public int updateLoanApplication(LoanApplication loanApplication) {
        loanApplication.setUpdateTime(DateUtils.getNowDate());
        return loanApplicationMapper.updateLoanApplication(loanApplication);
    }

    /**
     * 批量删除贷款申请
     *
     * @param applicationIds 需要删除的贷款申请主键
     * @return 结果
     */
    @Override
    public int deleteLoanApplicationByApplicationIds(Long[] applicationIds) {
        return loanApplicationMapper.deleteLoanApplicationByApplicationIds(applicationIds);
    }

    /**
     * 删除贷款申请信息
     *
     * @param applicationId 贷款申请主键
     * @return 结果
     */
    @Override
    public int deleteLoanApplicationByApplicationId(Long applicationId) {
        return loanApplicationMapper.deleteLoanApplicationByApplicationId(applicationId);
    }
}
